using System;
using System.Globalization;
using System.Runtime.Serialization;
namespace Net35.Xrm.Sdk
{
	[DataContract(Name = "Relationship", Namespace = "http://schemas.microsoft.com/xrm/2011/Contracts")]
	public sealed class Relationship : IExtensibleDataObject
	{
		private EntityRole? _primaryEntityRole;
		private string _schemaName;
		private ExtensionDataObject _extensionDataObject;
		[DataMember]
		public string SchemaName
		{
			get
			{
				return this._schemaName;
			}
			set
			{
				this._schemaName = value;
			}
		}
		[DataMember]
		public EntityRole? PrimaryEntityRole
		{
			get
			{
				return this._primaryEntityRole;
			}
			set
			{
				this._primaryEntityRole = value;
			}
		}
		public ExtensionDataObject ExtensionData
		{
			get
			{
				return this._extensionDataObject;
			}
			set
			{
				this._extensionDataObject = value;
			}
		}
		public Relationship()
		{
		}
		public Relationship(string schemaName)
		{
			this._schemaName = schemaName;
		}
		public override bool Equals(object obj)
		{
			Relationship relationship = obj as Relationship;
			return relationship != null && this.SchemaName == relationship.SchemaName && this._primaryEntityRole == relationship._primaryEntityRole;
		}
		public override int GetHashCode()
		{
			int num = (this._schemaName ?? string.Empty).GetHashCode();
			if (this._primaryEntityRole.HasValue)
			{
				num ^= this._primaryEntityRole.Value.GetHashCode();
			}
			return num;
		}
		public override string ToString()
		{
			return string.Format(CultureInfo.InvariantCulture, "{0}.{1}", new object[]
			{
				this._schemaName ?? string.Empty,
				this._primaryEntityRole.HasValue ? this._primaryEntityRole.ToString() : string.Empty
			});
		}
	}
}
